package cn.tedu.boot1.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

@Controller
public class HelloController {
//    @RequestMapping("/hello")
//    public void hello(HttpServletResponse response) throws IOException {
//        response.setContentType("text/html;charset=utf-8");
//        PrintWriter pw = response.getWriter();
//        pw.println("请求成功!");
//        pw.close();
//    }

/*    @RequestMapping("/hello")
    @ResponseBody // 此注解的作用是 通过返回值的方式给客户端响应数据
    public String hello(HttpServletRequest request) {
        //从请求中获取传递过来的参数
        String info = request.getParameter("info");
        return "请求成功";
    }*/

    @RequestMapping("/hello")
    @ResponseBody // 此注解的作用是 通过返回值的方式给客户端响应数据
    public String hello(String info){
        return "请求成功!"+info;
    }

    @RequestMapping("/nameAge")
    @ResponseBody
    public String nameAge(String name,int age){
        System.out.println("name = " + name + ", age = " + age);
        return "ok";
    }
}
